package tcm.com.gistone.database.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import tcm.com.gistone.database.entity.Bookinfo;
import tcm.com.gistone.database.entity.Special;

import java.util.List;

public interface BookinfoMapper {

    int deleteByPrimaryKey(Long bookId);

    int insert(Bookinfo record);

    int insertSelective(Bookinfo record);

    Bookinfo selectByPrimaryKey(Long bookId);

    int updateByPrimaryKeySelective(Bookinfo record);

    int updateByPrimaryKey(Bookinfo record);

    @Select("select * from tb_bookinfo where special_id = #{specialId}")
    @ResultMap("tcm.com.gistone.database.mapper.BookinfoMapper.BaseResultMap")
    List<Bookinfo> selectBySpecial(long specialId);

    @Select("select * from tb_bookinfo where special_id = #{specialId} and status >1 ")
    @ResultMap("tcm.com.gistone.database.mapper.BookinfoMapper.BaseResultMap")
    List<Bookinfo> selectAvaiBySpecial(long specialId);

    @Select("select * from tb_bookinfo where status >1 and status < 7 ")
    @ResultMap("tcm.com.gistone.database.mapper.BookinfoMapper.BaseResultMap")
    List<Bookinfo> selectAvai();


    @Select("select * from tb_bookinfo where special_id = #{specialId} and book_name = #{name}")
    @ResultMap("tcm.com.gistone.database.mapper.BookinfoMapper.BaseResultMap")
    Bookinfo selectOne(@Param("specialId") long specialId, @Param("name") String name);

    @Select("select * from tb_bookinfo where  book_name like  '% #{name} %'")
    @ResultMap("tcm.com.gistone.database.mapper.BookinfoMapper.BaseResultMap")
    List<Bookinfo> selectByName(@Param("name") String name);

    /*查询可以入库的书籍*/
    @Select("select * from tb_bookinfo where status = 1")
    @ResultMap("tcm.com.gistone.database.mapper.BookinfoMapper.BaseResultMap")
    List<Bookinfo> selectUnStore();

    /*查询准备好入库的书籍*/
    @Select("select * from tb_bookinfo where status = 2")
    @ResultMap("tcm.com.gistone.database.mapper.BookinfoMapper.BaseResultMap")
    List<Bookinfo> selectReadyToStore();
}